import { profileType1 } from './../store/reducer/user';
import request from '@/utils/request';

// 发送短信验证码
export const getcodeAPI = (mobile: string) => request({ url: '/v1_0/sms/codes/' + mobile });

// 用户认证（登录注册）
export type loginFormType = {
  mobile: string;
  code: string;
};
export const userLoginAPI = (data: loginFormType) =>
  request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data,
  });

/** 获取用户自己信息 */
export const getUserProfileAPI = () =>
  request({
    url: '/v1_0/user',
  });

/** 获取用户个人资料 */
export const getProfileAPI = () =>
  request({
    url: '/v1_0/user/profile',
  });

/** 编辑用户照片资料（头像、身份证照片） */
export const editPhotoAPI = (data: FormData) =>
  request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data,
  });

/** 编辑用户个人资料 */
export const editProfileAPI = (data: Partial<profileType1>) =>
  request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data,
  });
